package table;

import symbal.SymbalTable;
import symbal.constsymbal.ConstSymbal;

import java.util.Map;
import java.util.TreeMap;

public class Table {
    private static SymbalTable symbalTable = new SymbalTable();
    private static TreeMap<Integer, Character> errors = new TreeMap<>();
    private static int regindex = 0;

    public static SymbalTable getSymbalTable() {
        return symbalTable;
    }

    public static void addError(int lindex, char kind) {
        if (errors.containsKey(lindex)) {
            return;
        } else {
            errors.put(lindex, kind);
        }
    }

    public static void printError() {
        for (Map.Entry<Integer, Character> entry: errors.entrySet()) {
            System.out.println("" + entry.getKey() + " " + entry.getValue());
        }
    }

    public static String toError() {
        String str = "";
        for (Map.Entry<Integer, Character> entry: errors.entrySet()) {
            str += "" + entry.getKey() + " " + entry.getValue() + "\n";
        }
        return str;
    }

    public static boolean haveError() {
        return !errors.isEmpty();
    }
}
